package com.activities.api.data.server;

import java.util.Collection;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import com.activities.api.data.entities.Participant;
import com.activities.api.data.providers.ParticipantStore;
import com.google.inject.Inject;

@Path("/participantservice")
public class ParticipantServiceImpl extends ServiceImpl<Participant> implements ParticipantService {
	@Inject
	private ParticipantStore store;

	public ParticipantStore getStore() {
		return store;
	}

	public void setStore(ParticipantStore store) {
		this.store = store;
	}

	@GET
	@Path("/participants/{id}")
	@Produces("application/xml")
	@Override
	public Participant get(@PathParam("id") String id) {
		ParticipantStore store = getStore();
		
		return store.get(id);
	}

	@GET
	@Path("/participants/")
	@Produces("application/xml")
	@Override
	public Collection<Participant> getAll() {
		ParticipantStore store = getStore();
		
		return store.getAll();
	}

	@POST
	@Path("/participants/")
	@Consumes("application/xml")
	@Override
	public void save(Participant participant) {
		ParticipantStore store = getStore();
		
		store.save(participant);
	}

	@DELETE
	@Path("/participants/{id}")
	@Override
	public void delete(@PathParam("id") String id) {
		ParticipantStore store = getStore();

		store.delete(id);
	}

}
